//
//  WZRootMenuCell.m
//  ETong
//
//  Created by wanzhao on 15/12/17.
//  Copyright (c) 2015年 wanzhao. All rights reserved.
//

#import "WZRootMenuCell.h"
#import "WZTabBarButton.h"

@interface WZRootMenuCell ()

@property (nonatomic, weak) WZTabBarButton *menuButton;
@property (nonatomic, weak) UIView *line1;
@property (nonatomic, weak) UIView *line2;

@end

@implementation WZRootMenuCell

+ (WZRootMenuCell *)rootMenuCellWithTableView:(UITableView *)tableView
{
    static NSString *rootMeneCellId = @"rootMenuCellId";
    WZRootMenuCell *cell = [tableView dequeueReusableCellWithIdentifier:rootMeneCellId];
    if (cell == nil) {
        cell = [[WZRootMenuCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:rootMeneCellId];
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = ClearColor;
        self.contentView.backgroundColor = ClearColor;
        WZTabBarButton *button = [WZTabBarButton buttonWithType:UIButtonTypeCustom];
        [button setTitleColor:RGBCOLORWITH16COLOR(0xffffff) forState:UIControlStateNormal];
        button.titleLabel.font = Font10;
        button.userInteractionEnabled = NO;
        [self.contentView addSubview:button];
        self.menuButton = button;
        
        
        
        UIView *line1 = [[UIView  alloc] init];
        line1.backgroundColor = RGBCOLORWITH16COLOR(0x32a2fc);
        [self.contentView addSubview:line1];
        self.line1 = line1;
        
        UIView *line2 = [[UIView alloc] init];
        line2.backgroundColor = RGBCOLORWITH16COLOR(0x2a87d4);
        [self.contentView addSubview:line2];
        self.line2 = line2;
    
    }
    return self;
}

- (void)setItem:(WZRootMenuItem *)item
{
    _item = item;
    [self.menuButton setImage:[UIImage imageNamed:item.icon] forState:UIControlStateNormal];
    [self.menuButton setTitle:item.title forState:UIControlStateNormal];
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.menuButton.frame = CGRectMake(0, 0, OppositeWidthRate(60), self.height);
    self.line1.frame =CGRectMake(OppositeWidthRate(15), self.height - 1.0f, OppositeWidthRate(60) - OppositeWidthRate(30), 0.5f);
    self.line2.frame = CGRectMake(OppositeWidthRate(15), self.height - 0.5f, OppositeWidthRate(60) - OppositeWidthRate(30), 0.5f);
}
@end
